from Module.MainWindow.od_header import *
# from win32api import GetSystemMetrics

# class MySplash(QWidget):
#     def __init__(self):
#         super(MySplash, self).__init__()
#         self.setAttribute(Qt.WA_TranslucentBackground, True) #设置背景透明
#         self.setWindowFlags(Qt.FramelessWindowHint) #设置无边框
#         # self.setFixedSize(500,800)
#         windowWidth = GetSystemMetrics(0)
#         windowHeight = GetSystemMetrics(1)
#         self.setGeometry(windowWidth / 2 - 500, windowHeight / 2 - 214, 1000,427)
#         self.text = "Initial Site-Packages......0%"
#         self.setFont(APPFONT)
#
#     def paintEvent(self, QPaintEvent):
#         self.p = QPainter(self)
#         self.p.setPen(QPen())
#         self.p.setBrush(QBrush())
#         self.p.drawPixmap(0, 0, QPixmap(":icons/PROXIMA_splash.png"))
#         self.p.setFont(QFont(FONTSTR, 20))
#         self.p.drawText(QRect(200, 217, 600, 200), Qt.AlignCenter, self.text)
#
#     def setText(self,text):
#         self.text = text
#         self.paintEvent(QPaintEvent)
#
# class WorkerTimer(QThread):
#     sinOut = pyqtSignal(object)
#
#     def __init__(self,sp,parent=None):
#         super(WorkerTimer, self).__init__(parent)
#         self._isPause = False
#         self.sp = sp
#         self.cond = QWaitCondition()
#         self.mutex = QMutex()
#
#     def __del__(self):
#         self.wait()
#
#     def pause(self):
#         self._isPause = True
#
#     def resume(self):
#         self._isPause = False
#         self.cond.wakeAll()
#
#     def run(self):
#         self.mutex.lock()
#         if self._isPause:
#             self.cond.wait(self.mutex)
#         self.sinOut.emit(self.sp)
#         self.msleep(20)
#         self.mutex.unlock()

def load_data(sp):
    import time
    for i in range(0, 6):  # 模拟主程序加载过程
        time.sleep(0.2)  # 加载数据
        sp.setText("Dr.Octopus Initial Packages{}".format('.'*i)+'{}%'.format(20*i))
        sp.update()
        qApp.processEvents()  # 允许主进程处理事件

def load_dataSplash(sp):
    for i in range(0, 6):
        QThread.msleep(200)
        sp.setText("Dr.Octopus Initial Packages{}".format('.'*i)+'{}%'.format(20*i))
        sp.update()
        qApp.processEvents()

def have_qstring():
    return not (sys.version_info.major >= 3 or QT_VERSION_STR.startswith('5.'))

# global sp
# sp = None

# v_compare = QVersionNumber(5,6,0)
# v_current,_ = QVersionNumber.fromString(QT_VERSION_STR)  #获取当前Qt版本
# if QVersionNumber.compare(v_current,v_compare) >=0 :
#     QApplication.setAttribute(Qt.AA_EnableHighDpiScaling)   #Qt从5.6.0开始，支持High-DPI
#     app = QApplication(sys.argv)    #
# else:
#     app = QApplication(sys.argv)
#     font = QFont(FONTSTR)
#     pointsize = font.pointSize()
#     font.setPixelSize(pointsize*90/72)
#     app.setFont(font)

# app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())
# app.setWindowIcon(QIcon(":/icons/proxima"))
# sp = MySplash()
# sp.show()
# load_dataSplash(sp)
# qApp.processEvents()          # 处理主进程事件